package com.eques.database.dao

import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import androidx.room.Update
import com.eques.database.DevList
import kotlinx.coroutines.flow.Flow

@Dao
interface DevListDao {
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    fun insertBdyList(user: DevList)

    @Query("SELECT * FROM devlist WHERE user_name=:userName AND bid=:devId")
    fun getBdyList(userName: String, devId: String): List<DevList>

    @Query("SELECT * FROM devlist WHERE user_name=:userName AND bid=:devId LIMIT 1")
    fun getBdyListEntry(userName: String, devId: String): DevList

    @Query("SELECT * FROM devlist WHERE user_name=:userName")
    fun getUserBdyList(userName: String): List<DevList>

    @Update
     fun updateBdyList(user: DevList)

    @Query("DELETE FROM devlist WHERE user_name = :userName")
    fun delete(userName: String): Int
}